<template>
<div>
  <div class="top">
    <input type="text" v-model="nickname" placeholder="最多可输入15个字">
  </div>
  <div class="bottom">
    <div class="box">
      <p class="btn" @click="storage">保存</p>
    </div>
  </div>
</div>
</template>

<script>
import {getInfo, user} from "@/utils/api";
import {Toast} from "vant";
export default {
  name: "set-info",
  data(){
    return{
      nickname: this.$route.query.nickname,
      avatar:''
    }
  },
  created() {
    // console.log(this.nickname)
    getInfo().then(res=> {
      this.avatar = res.data.avatar
    })
  },
  methods:{
    storage(){//修改用户昵称
      user({nickname: this.nickname,avatar:this.avatar}).then(res=>{
        // console.log(res)
        if(res.code === 200){
          this.$router.go(-1)
        }else {
          Toast(res.msg)
        }
      })
    }
  }
}
</script>

<style scoped lang="scss">
.top {
  background-color: #fff;
  padding: 0 15px;
  height: 48px;
  input {
    width: 100%;
    height: 100%;
    border: none;
    font-size: 15px;
  }
}
.bottom {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 50px;
  //overflow: hidden;
  //box-sizing: border-box;
  background-color: white;
  .box {
    margin: 6.5px 15.5px;
    height: 100%;
    .btn {
      width: 100%;
      height: 37px;
      background: #e60012;
      border-radius: 37px;
      text-align: center;
      line-height: 39px;
      color: #fff;
      font-size: 13px;
      font-weight: bold;
    }
  }
}
</style>